<?php
/**
 * Created by PhpStorm.
 * 物流系统对接处理
 * User: caicm
 * Date: 2017/7/3
 * Time: 11:55
 */

namespace WMApi\Controller;


use WMApi\Service\BscService;

class BscController extends SellerBaseController {

    /**
     * 物流系统回调处理
     * Created By caicm
     * @param order_sn 订单号
     * @param contact 操作者姓名
     * @param phone 操作者电话
     * @param op_time 操作时间
     * @param best_time 延迟订单时间
     * @param op_type 操作类型 1:[开始配送] 2:[完成配送] 3:[已到站] 4:[需回仓] 5:[延迟订单] 6:[配送退单] 7:[问题单] 8 司机揽件，9返回揽件 10：回仓确认
     * @param sign 此次sign 开发者可由此判断是否是 bsc 服务器数据
     * @param remark 备注
     */
    public function bsc_notice(){
        $data_json = str_replace('&quot;','"',I("post.data"));
        $data_json = json_decode($data_json, true);

        $order_sn = $data_json['order_sn'];
        $contact = $data_json['contact'];
        $phone = $data_json['phone'];
        $op_time = $data_json['op_time'];
        $best_time = $data_json['best_time'];
        $op_type = $data_json['op_type'];
        $sign = $data_json['sign'];
        $remark = $data_json['remark'];


        /*$order_sn = I('post.order_sn');
        $contact = I('post.contact');
        $phone = I('post.phone');
        $op_time = I('post.op_time');
        $best_time = I('post.best_time');
        $op_type = I('post.op_type');
        $sign = I('post.sign');
        $remark = I('post.remark');*/

        if(empty($order_sn) || empty($sign) || empty($op_type) ){
            returnApiError('参数有误');
        }

        $bsc_service = new BscService();

        $state = $bsc_service->bsc_notice($order_sn, $contact, $phone, $op_time, $best_time, $op_type, $sign, $remark);
        if($state){
           die('success');
        }else{
            returnApiError('操作失败');
        }

    }

    /**
     * 订单查询
     * Created By caicm
     * @param order_sn 订单号
     */
    public function select_order(){
        $order_sn = I('post.order_sn');

        if(empty($order_sn) ){
            returnApiError('参数有误');
        }

        $bsc_service = new BscService();
        $state = $bsc_service->select_order_status($order_sn);
        returnApiSuccess($state);
    }



}